package com.dlg.commons.constant;

import java.math.BigInteger;

/**
 * Created by zhangjinxia on 2017/8/10.
 */
public class RedisKeyConstants {

    public static final String separator = ":";

    public static final String userLoginKeyPrefix = "login:user:";

    public static final String userDetailInfoRpcVoPrefix = "user:detail:rpc:vo:";

    public static final String userRegisterRpcVoPrefix = "user:register";

    public static final String userRegisteredFlagPrefix = "registered:flag:";

    public static final String dictionaryDataPrefix = "dictionary:data:";

    public static final String dictionaryGroupAndStatusPrefix = "dictionary:group:";

    public static String getUserLoginKey(String phone, String userType){
        StringBuilder builder = new StringBuilder(userLoginKeyPrefix);
        return builder.append(phone).append(separator).append(userType).toString();
    }

    public static String getUserRegisterKey(BigInteger id){
        StringBuilder builder = new StringBuilder(userRegisterRpcVoPrefix);
        return builder.append(separator).append(id).toString();
    }

    public static String getUserDetailInfoRpcVoKey(BigInteger userId){
        StringBuilder builder = new StringBuilder(userDetailInfoRpcVoPrefix);
        return builder.append(userId).toString();
    }

    public static String getUserRegisteredFlag(String phone, String userType){
        StringBuilder builder = new StringBuilder(userRegisteredFlagPrefix);
        return builder.append(phone).append(separator).append(userType).toString();
    }

    public static String getDictionaryData(String code){
        StringBuilder builder = new StringBuilder(dictionaryDataPrefix);
        return builder.append(code).toString();
    }

    public static String getDictionaryByGroupAndStatus(String groupCode, Short status){
        StringBuilder builder = new StringBuilder(dictionaryGroupAndStatusPrefix);
        return builder.append(groupCode).append(separator).append(status).toString();
    }
}
